package pojo;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "Address")
@SequenceGenerator(name = "bryceq2", sequenceName = "seq02", initialValue = 1, allocationSize = 1)
public class Address {

	@Id
	@GeneratedValue(generator = "bryceq2", strategy = GenerationType.SEQUENCE)
	private Integer id;
	private String city;
	private String zipcode;
	// @OneToOne(targetEntity=Merchant.class)//default regonize
//	@OneToOne(fetch = FetchType.EAGER,cascade={CascadeType.PERSIST,CascadeType.REMOVE})
	@OneToOne(fetch = FetchType.EAGER,cascade={CascadeType.ALL})
	@JoinColumn(name = "m_id")//外键
	private Merchant merchant;

	public Integer getId() {
		return id;
	}

	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getZipcode() {
		return zipcode;
	}

	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}

	@Override
	public String toString() {
		return "Address [id=" + id + ", city=" + city + ", zipcode=" + zipcode + "]";
	}

	public Address() {
		super();
		// TODO Auto-generated constructor stub
	}

}
